#!/usr/bin/env python
# -*- coding: utf-8 -*-
# title       :
# author      : jarry

import sys
import os
import logging
from SceneCheckTool.checkScript.CheckBase import CheckBase

try:
    import maya.cmds as cmds
    import pymel.core as pm
    import jarryLibs.mayakit.MayaUtils as mu
    reload(mu)
except:
    pass

logging.basicConfig()
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)


class EmptyFilePath(CheckBase):
    def __init__(self):
        super(EmptyFilePath, self).__init__()
        pass

    def check_empty_file(self):
        maya_file_list = pm.ls(type='file') + pm.ls(type='aiImage')

        error_node_list = []
        for mfile in maya_file_list:
            pass
            abs_file_path = ''
            if mfile.type() == 'file':
                abs_file_path = mfile.fileTextureName.get()
            elif mfile.type() == 'aiImage':
                abs_file_path = mfile.filename.get()
            if not abs_file_path:
                error_node_list.append(mfile.name())
        return error_node_list

    def check(self):

        result_proc = self.check_empty_file()
        if result_proc:
            result_log = u'Error:%s\n' % result_proc
        else:
            result_log = u'Succeed:没有问题\n'

        return result_log

    def fix(self):
        pass

